#include<iostream>
using namespace std;
int main()
{
	int l[100010] = { 0 }, r[100010] = { 0 }, n, y = 0, x = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> l[i] >> r[i];
	}
	for (int i = 1; i <= n; i++)
	{
		x = r[i] - l[i - 1];
		if (y < x)
		{
			y = x;
		}
	}
	cout << y << endl;
	system("pause");
	return 0;
}